'use strict'

const path = require('path')
const webpack = require('webpack')

module.exports = {
    entry: [
      // 'webpack-hot-middleware/client',
      './src/index.tsx',
    ],
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'src'),
        // publicPath: '/static/',
    },
    plugins: [
      new webpack.NoErrorsPlugin(),
      new webpack.HotModuleReplacementPlugin(),
    ],

    // Enable sourcemaps for debugging webpack's output.
    devtool: 'source-map',

    devServer: {
      // contentBase: path.resolve(__dirname, 'src'),
      contentBase: path.resolve(__dirname, 'src'),
      historyApiFallback: true,
      hot: true,
      inline: true,
      progress: true,
      // Display only errors to reduce the amount of output.
      stats: 'errors-only',
      host: '0.0.0.0',
      port: 8988,
    },

    resolve: {
        // Add '.ts' and '.tsx' as resolvable extensions.
        extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
    },

    module: {
        loaders: [
            // All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
            { test: /\.tsx?$/, loader: 'ts-loader' }
        ],

        preLoaders: [
            // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
            { test: /\.js$/, loader: 'source-map-loader' }
        ]
    },
};